﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel;
using System.Collections.Generic;
using System.ServiceModel.Channels;

namespace OnlineGameLibrary.Contract
{
    [ServiceContract(Namespace = "http://gameservice", CallbackContract = typeof(IGameRoomServiceCallBack))]
    public interface IGameRoomService
    {
        //[OperationContractAttribute(AsyncPattern = true)]
        //IAsyncResult BeginGetDefaultGameConfig(string gamename, AsyncCallback callback, object asyncState);
        //GameConfig EndGetDefaultGameConfig(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginUserHeartBeat(AsyncCallback callback, object asyncState);
        void EndUserHeartBeat(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginUpdatePlayerState(PlayerState state, AsyncCallback callback, object asyncState);
        OperationResult EndUpdatePlayerState(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginGetGameList(AsyncCallback callback, object asyncState);
        List<GameInfo> EndGetGameList(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginGetGameRooms(AsyncCallback callback, object asyncState);
        List<GameRoom> EndGetGameRooms(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginCreateGameRoom(GameConfig config, AsyncCallback callback, object asyncState);
        GameRoom EndCreateGameRoom(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginUpdateGameConfig(GameConfig config, AsyncCallback callback, object asyncState);
        OperationResult EndUpdateGameConfig(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginAttendGameRoom(Guid gameid, AsyncCallback callback, object asyncState);
        GameRoom EndAttendGameRoom(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginLeaveGameRoom(AsyncCallback callback, object asyncState);
        OperationResult EndLeaveGameRoom(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginGameStart(AsyncCallback callback, object asyncState);
        OperationResult EndGameStart(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginLoadGameConfig(AsyncCallback callback, object asyncState);
        GameConfig EndLoadGameConfig(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginLoadPlayer(AsyncCallback callback, object asyncState);
        List<Player> EndLoadPlayer(IAsyncResult result);

        [OperationContractAttribute(AsyncPattern = true)]
        IAsyncResult BeginPlayerLogin(string name, AsyncCallback callback, object asyncState);
        Player EndPlayerLogin(IAsyncResult result);

        [OperationContract(AsyncPattern = true, Action = "http://gameaction", IsOneWay = true)]
        IAsyncResult BeginSendMessageToGame(Message msg, AsyncCallback callback, object asyncState);
        void EndSendMessageToGame(IAsyncResult result);

        //[OperationContract(Action = "http://gameaction", IsOneWay = true)]
        //void SendMessageToGame(Message msg);
    }

    public interface IGameRoomServiceCallBack
    {
        [OperationContract(Action = "http://gameaction", IsOneWay = true)]
        void SendGameMessage(Message msg);
    }
}
